//
//  MyCollectionCell.m
//  ShangHaiTuJI
//
//  Created by xiaoxiangtuji on 2017/9/27.
//  Copyright © 2017年 xiaoxiangtuji. All rights reserved.
//

#import "MyCollectionCell.h"

@implementation MyCollectionCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        UIImageView *iconImageView = [[UIImageView alloc] init];
        iconImageView.backgroundColor = [UIColor cyanColor];
        [self.contentView addSubview:iconImageView];
        [iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(125, 72));
            make.left.equalTo(self.contentView.mas_left).offset(scaleLeftAndRight(12));
            make.centerY.equalTo(self.contentView.mas_centerY);
        }];
        UILabel *namelabel = [[UILabel alloc] init];
        namelabel.font = [UIFont systemFontOfSize:14];
        namelabel.textColor = COLOR_HEX(0x121212);
        namelabel.text = @"2017超级英雄荣耀之战";
        [self.contentView addSubview:namelabel];
        [namelabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView.mas_top).offset(scaleTopAndBottom(12));
            make.left.equalTo(iconImageView.mas_right).offset(scaleLeftAndRight(10));
            make.right.equalTo(self.contentView.mas_right).offset(scaleLeftAndRight(-10));
            make.height.mas_equalTo(scaleTopAndBottom(14));
        }];
        UILabel *descripLabel = [[UILabel alloc] init];
        descripLabel.numberOfLines = 0;
        descripLabel.font = [UIFont systemFontOfSize:12];
        descripLabel.textColor = COLOR_HEX(0xABABAB);
        descripLabel.text = @"金卡价疯狂拉升房价奥拉夫骄傲了开发金坷垃复健科";
        [self.contentView addSubview:descripLabel];
        [descripLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(namelabel.mas_bottom).offset(scaleTopAndBottom(7));
            make.left.equalTo(iconImageView.mas_right).offset(scaleLeftAndRight(10));
            make.height.mas_equalTo(scaleTopAndBottom(27));
            make.right.equalTo(self.contentView.mas_right).offset(scaleLeftAndRight(-10));
        }];
        UILabel *onlineLabel = [[UILabel alloc] init];
        onlineLabel.text = @"#线上#";
        onlineLabel.font = [UIFont systemFontOfSize:10];
        onlineLabel.textColor = COLOR_HEX(0xF0982E );
        [self.contentView addSubview:onlineLabel];
        [onlineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.mas_equalTo(scaleLeftAndRight(32));
            make.left.equalTo(iconImageView.mas_right).offset(scaleLeftAndRight(10));
            make.height.mas_equalTo(scaleTopAndBottom(10));
            make.bottom.equalTo(self.contentView.mas_bottom).offset(scaleTopAndBottom(-12));
        }];
        UIButton *shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [shareBtn setBackgroundImage:[UIImage imageNamed:@"collectionShare"] forState:UIControlStateNormal];
        [self.contentView addSubview:shareBtn];
        [shareBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(onlineLabel.mas_right).offset(scaleLeftAndRight(105));
            make.size.mas_equalTo(CGSizeMake(11, 11));
            make.bottom.equalTo(self.contentView.mas_bottom).offset(scaleTopAndBottom(-12));
        }];
        UIButton *oldtimeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [oldtimeBtn setTitle:@"28天前" forState:UIControlStateNormal];
        oldtimeBtn.titleLabel.font = [UIFont systemFontOfSize:10];
        [oldtimeBtn setTitleColor:COLOR_HEX(0xB3B3B3) forState:UIControlStateNormal];
        [self.contentView addSubview:oldtimeBtn];
        [oldtimeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView.mas_right).offset(scaleLeftAndRight(-10));
            make.bottom.equalTo(self.contentView.mas_bottom).offset(scaleTopAndBottom(-12));
            make.left.equalTo(shareBtn.mas_right).offset(scaleLeftAndRight(22));
            make.height.mas_equalTo(scaleTopAndBottom(11));
        }];
//        oldtimeBtn.backgroundColor = [UIColor redColor];
    }
    return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
